set more off
set matsize 800

log using may06_immig_ddd_cluster.log, replace

use c:/aimee/pr2005/us_1990/immig_1990/immig21plus90

keep if bpld == 11000 | bplg == 250 | bpld == 51500 | bplg == 200 | bpld == 26010 

* drop if bplg == 110
* keep if engoff == 0
* keep if hispdum 
* drop if bpld < 15000
* keep if bplg == 200

keep if yrimmig >= 959 & yrimmig < 990
* keep if yrimmig > 959 & yrimmig < 990
* keep if yrimmig > 964 & yrimmig < 981
* keep if yrimmig > 959 & yrimmig <= 981


/*
keep if yob >= 1924 & yob <= 1943
gen older = yob <= 1933
*/

/*
keep if yob >= 1934 & yob <= 1953
gen older = yob <= 1943
*/

/*
keep if yob >= 1914 & yob <= 1933
gen older = yob <= 1923
*/

keep if yob >= 1924 & yob <= 1963
gen older = yob <= 1933
gen secondhalf = (yob >= 1944 & yob <= 1963)

gen yrssch_all = .
replace yrssch_all = yrssch if cenyr == 1990
replace yrssch_all = 0 if yrssch == 0 & cenyr == 1980
replace yrssch_all = 3 if (yrssch >= 1 & yrssch <= 4) & cenyr == 1980
replace yrssch_all = 7 if (yrssch >= 5 & yrssch <= 8) & cenyr == 1980
replace yrssch_all = yrssch if (yrssch >= 9 & yrssch <= 12) & cenyr == 1980
replace yrssch_all = 14 if (yrssch >= 13 & yrssch <= 15) & cenyr == 1980
replace yrssch_all = yrssch if yrssch == 16 & cenyr == 1980
replace yrssch_all = 18 if yrssch > 16 

table yrssch_all older, c(mean yrarrive) 
table yrssch_all older, c(mean aamin) 

tab yrssch_all if ~older
tab yrssch_all if older

gen treat = older*bornpr

gen treatpseudo = treat
replace treatpseudo = bornpr if yob >= 1944 & yob <= 1953

gen potex = age-yrssch-6
gen potexsq = potex^2
gen potex_4463 = potex*secondhalf
gen potexsq_4463 = potexsq*secondhalf

gen femalepr = female*bornpr
gen female_4463 = female*secondhalf
gen femalepr_4463 = femalepr*secondhalf

gen bpldsecondhalf = bpld*10 + secondhalf
tab bpldsecondhalf, gen(dbpld)
drop dbpld1

gen yrssch_all_yob= yrssch_all*10 + secondhalf
tab yrssch_all_yob, gen(deduc)
drop deduc1 


gen yrssch_all_yobpr = yrssch_all_yob*bornpr
tab yrssch_all_yobpr, gen(deducpr)


gen yrimmig_yob = yrimmig*10 + secondhalf
tab yrimmig_yob, gen(dyrimmig)
drop dyrimmig1

gen yrimmig_yobpr = yrimmig_yob*bornpr
tab yrimmig_yobpr, gen(dyrimmigpr)
drop dyrimmigpr1 dyrimmigpr2


gen groupid = yob*10+bornpr

***


* Puerto Rico vs Cuba

areg speakeng treat* dbpld* deduc* potex* dyrimmig* female* if bplg == 250 | bpld == 11000, absorb(yob) cluster(groupid)
areg engwell treat* dbpld* deduc* potex* dyrimmig* female* if bplg == 250 | bpld == 11000, absorb(yob) cluster(groupid)
areg verywell treat* dbpld* deduc* potex* dyrimmig* female* if bplg == 250 | bpld == 11000, absorb(yob) cluster(groupid)


* Puerto Rico vs Philippines

areg speakeng treat* dbpld* deduc* potex* dyrimmig* female* if bpld == 51500 | bpld == 11000, absorb(yob) cluster(groupid)
areg engwell treat* dbpld* deduc* potex* dyrimmig* female* if bpld == 51500 | bpld == 11000, absorb(yob) cluster(groupid)
areg verywell treat* dbpld* deduc* potex* dyrimmig* female* if bpld == 51500 | bpld == 11000, absorb(yob) cluster(groupid)


* Puerto Rico vs Mexico

areg speakeng treat* dbpld* deduc* potex* dyrimmig* female* if bplg == 200 | bpld == 11000, absorb(yob) cluster(groupid)
areg engwell treat* dbpld* deduc* potex* dyrimmig* female* if bplg == 200 | bpld == 11000, absorb(yob) cluster(groupid)
areg verywell treat* dbpld* deduc* potex* dyrimmig* female* if bplg == 200 | bpld == 11000, absorb(yob) cluster(groupid)


* Puerto Rico vs Dominican Republic

areg speakeng treat* dbpld* deduc* potex* dyrimmig* female* if bpld == 26010| bpld == 11000, absorb(yob) cluster(groupid)
areg engwell treat* dbpld* deduc* potex* dyrimmig* female* if bpld == 26010 | bpld == 11000, absorb(yob) cluster(groupid)
areg verywell treat* dbpld* deduc* potex* dyrimmig* female* if bpld == 26010 | bpld == 11000, absorb(yob) cluster(groupid)



log close





